from datetime import datetime
# from pydantic import 
from sqlmodel import  SQLModel,text,Field,Column
import sqlalchemy as sa

class SQLModelBase(SQLModel):
    id: int | None = Field(default=None, primary_key=True, title="主键", sa_column_kwargs={"comment": "主键"})
    createTime: datetime | None = Field(
        default=None,
        sa_type=sa.DateTime(timezone=True),
        sa_column_kwargs={"server_default": sa.func.now(),"comment":"创建时间","name":"create_time"},
        nullable=False,
    )    
    modifyTime: datetime | None = Field(
        default=None,
        sa_type=sa.DateTime(timezone=True),
        sa_column_kwargs={
            "server_default": sa.func.now(),
            "onupdate": sa.func.now(),
            "comment":"修改时间",
            "name":"modify_time"
        },  
    )
    delFlag: int  = Field(default=0, nullable=False, title="删除标志（0代表存在 1代表删除）",
                          sa_column_kwargs={"server_default":text("0"),"comment":"删除标志（0代表存在 1代表删除）","name":"del_flag"})
    version: int  = Field(default=0, nullable=False, title="乐观锁版本号",
                         sa_column_kwargs={"server_default":text("0"),"comment":"乐观锁版本号"})
